@layout("/common/_containersd.html"){
<style>
    ul{padding: 0;}  .ulBox>li{margin: 10px 0;} .btnBox{padding-left: 15px;} #calendar th.fc-resource-cell{cursor:pointer;}
    #wrap > #calendar .fc-toolbar{margin-bottom: 17px;}
    #wrap > #calendar table table th {  line-height: 42px; background: linear-gradient(#f7f7f7, #d8d8d8) ;color: #319DB5}
    #wrap > #calendar table table th:nth-child(1){ padding: 0 14px; }
    #wrap > #calendar .fc-bg tr td:nth-child(1),.fc-content-skeleton table tr td:nth-child(1){ padding: 0 14px; }
    #wrap > #calendar table table th:hover{color: #23527c}
    #wrap > #calendar .fc-center h2 {  border: 1px solid #A9A9A9;  margin: 0; padding: 5px 40px;font-size: 22px;height: 45px;line-height: 34px;font-weight: bold; }
    #wrap > #calendar .fc-center button {  background: white;  border-radius: 0;  border: 1px solid #a9a9a9; height: 45px; }
    #wrap > #calendar .fc-center button:first-of-type {  border-right: none;  border-top-left-radius: 4px;;  border-bottom-left-radius: 4px;  }
    #wrap > #calendar .fc-center button:last-of-type {  border-left: none;  margin: 0;  border-top-right-radius: 4px;  border-bottom-right-radius: 4px;  }

    .ulBox>li span:first-of-type{ color: #666666; display: inline-block ;width: 90px;text-align: right;margin-right: 10px;font-size: 18px;}
    .btnBox>button{border:1px solid #cccccc;border-radius: 4px;background: white;color: #333333;}
    #statePrompting{position: fixed;bottom: 0;height: 36px;background: white;z-index: 9;width: 100%;line-height: 36px;}
    #statePrompting .state{display: inline-block;width: 15px;height: 15px;flex: 1;margin:0 5px 0 15px;vertical-align: middle}

    .gray-bg .layui-layer .layui-layer-content{border: 1px solid #999999;border-radius: 5px;}

    #wrap > #calendar .fc-slats table tr:nth-child(4) td:nth-child(1){  border-bottom: 1px solid #DDDDDD !important;  }
    #wrap > #calendar .fc-slats table tr:nth-child(8) td:nth-child(1){  border-bottom: 1px solid #DDDDDD !important;  }
    #wrap > #calendar .fc-slats table tr:nth-child(12) td:nth-child(1){  border-bottom: 1px solid #DDDDDD !important;  }
    #wrap > #calendar .fc-slats table tr:nth-child(16) td:nth-child(1){  border-bottom: 1px solid #DDDDDD !important;  }
    #wrap > #calendar .fc-slats table tr:nth-child(20) td:nth-child(1){  border-bottom: 1px solid #DDDDDD !important;  }
    #wrap > #calendar .fc-slats table tr:nth-child(24) td:nth-child(1){  border-bottom: 1px solid #DDDDDD !important;  }
    #wrap > #calendar .fc-slats table tr:nth-child(28) td:nth-child(1){  border-bottom: 1px solid #DDDDDD !important;  }
    #wrap > #calendar .fc-slats table tr:nth-child(32) td:nth-child(1){  border-bottom: 1px solid #DDDDDD !important;  }
    #wrap > #calendar .fc-slats table tr:nth-child(36) td:nth-child(1){  border-bottom: 1px solid #DDDDDD !important;  }


    #dataBox{display: none;position: absolute;z-index: 9;box-shadow: 0 1px 5px #cccccc;width: 250px;overflow:scroll; height:400px;background: white;border: 1px solid #cccccc;border-radius: 5px;}
    #dataBox>#dataUl{padding-top: 10px;}
    #dataBox>#dataUl>li{padding-left: 10px;}
    #dataBox>#dataUl>li:hover{background: #e0faff}
    #dataBox>#dataUl p{margin: 0;}

    .shadow{  box-shadow: 0 0 20px #666;}

</style>
<div style="display: none">
    <input type="hidden" id="startDocumentValue" value="">
    <input type="hidden" id="endDocumentValue" value="">
    <input type="hidden" id="wgz" value="2">
</div>
<div class="ibox float-e-margins ">
    <div class="ibox-content record_box">
        <div class="row">
            <div id='wrap'>
                <div style="position: absolute;top: 19px;right: 231px;">
                    <div style="width: 250px;height: 42px;border: 1px solid #cccccc;border-radius: 5px;">
                        <span class="glyphicon glyphicon-search" style="left: 10px;top: 9px;"></span>
                        <input type="text" id="reach" placeholder="姓名/电话/拼音" oninput="search()" style="width: 85%;height: 39px;border: none;float: right;outline:none;margin-top: 1px">
                    </div>
                    <div id="dataBox">
                        <ul id="dataUl"></ul>
                        <div style="padding: 5px;text-align: center;" class="js-load-more"><a href="javascript:;">点击加载更多</a></div>
                    </div>
                </div>
                <div style="position: absolute;top: 20px;right: 166px;">
                    <button type="button" class="btn" id="pipei" onclick="reservationMatching()"
                            style="background: #5e8aa3;color: white">匹配
                    </button>
                </div>
                <button class="btn" onclick="btnRefetchEvents()" type="button" style="position: absolute;right: 86px;top:18px;border: 1px solid #cccccc;background: white;outline:none;padding: 8px 17px;"><span class="glyphicon glyphicon-refresh" style="vertical-align: middle;margin-bottom: 4px;"></span></button>
                <div id='calendar' style="margin-bottom: 16px;"></div>
            </div>
        </div>
    </div>
    <div id="statePrompting" class="clearfix">
        <div style="float: right;width:590px;display: flex">
            <div><span class="state" style="background: #4099ff"></span>预约</div>
            <div><span class="state" style="background: #017cdc"></span>确认</div>
            <div><span class="state" style="background: #10428b"></span>挂号</div>
            <div><span class="state" style="background: #ffba40"></span>治疗中</div>
            <div><span class="state" style="background: #2dc87e"></span>治疗完成</div>
            <div><span class="state" style="background: #61b740"></span>离开</div>
            <div><span class="state" style="background: gray"></span>失约</div>
        </div>
    </div>
</div>

<link rel="stylesheet" href="${ctxPath}/static/modular/fullcalendar/fullcalendar.css">
<link href='${ctxPath}/static/modular/fullcalendar//fullcalendar.print.min.css' rel='stylesheet' media='print'/>
<script src="${ctxPath}/static/modular/fullcalendar/lib/moment.min.js"></script>
<script src="${ctxPath}/static/modular/fullcalendar/lib/jquery.min.js"></script>
<script src="${ctxPath}/static/modular/fullcalendar/lib/jquery-ui.min.js"></script>
<script src="${ctxPath}/static/modular/fullcalendar/fullcalendar.js"></script>
<script src="${ctxPath}/static/modular/fullcalendar/scheduler.min.js"></script>
<script src="${ctxPath}/static/modular/fullcalendar/locale/zh-cn.js"></script>
<script src="${ctxPath}/static/modular/arrival/customer/customer_reservationViews.js"></script>

<script>
    var arr;
    $(function () {
        $('#calendar').fullCalendar({
            header: {
                left: 'agendaDay,agendaWeek',
                center: 'prev title next',
                right: 'today'
            },
            views: {
                agendaDay: {
                    groupByResource: true,
                }
            },
            resources: [],
            droppable: true,
            defaultView: 'agendaDay',       //进入组件默认渲染的视图
            allDaySlot: false,               //隐藏 "全天" 信息
            navLinks: true,
            selectable: true,               //允许用户可以长按鼠标选择多个区域
            selectHelper: true,             //周/日视图在选择时是否预先画出“日程区块”的样式出来
            editable: true,                 //支持Event日程拖动修改，默认false
            eventLimit: true,
            lazyFetching: true,            //是否启用懒加载技术
            handleWindowResize:true,
            nowIndicator: true,              //周/日视图中显示今天当前时间点（以红线标记）
            titleFormat: 'dddd YYYY-MM-DD',       //顶部title区域格式化
            minTime: "08:00:00",             //周/日视图左边时间线显示的最小日期
            maxTime: "18:00:00",             //周/日视图左边时间线显示的最大日期
//            aspectRatio: 2.3,               //宽度:高度 比例，默认1.35，
//            contentHeight:800,
            height:window.innerHeight-52,
            windowResize: function(view) {
                $('#calendar').fullCalendar('option', 'height', window.innerHeight-52);
            },
            slotDuration: "00:15:00",      //一格时间槽代表多长时间
            slotLabelFormat: 'HH',
            slotLabelInterval: "00:60:00", //日期视图左边那一列多长间隔显示一条日期文字
            slotLabelFormats: 'mm',
            slotLabelIntervals: "00:15:00", //日期视图左边那一列多长间隔显示一条日期文字
            selectMinDistance: 30,
            select: function (startDate, endDate, jsEvent, view, resource) {
                var start = startDate.format('YYYY-MM-DD HH:mm:ss');
                var end = endDate.format('YYYY-MM-DD HH:mm:ss');
                var start1 = new Date(start);
                var end1 = new Date(end);
                var continued = parseInt(end1 - start1)/1000/60;
                var docName;
                if (view.type == 'agendaDay') {
                    docName = resource.title;
                } else {
                    docName = '';
                }
                if(docName != ''){
                    var eventData = start + "," + end + "," + docName + "," + continued;
                    var index = layer.open({
                        type: 2,
                        title: '添加预约客户',
                        area: ['60%', '90%'], //宽高
                        fix: true, //不固定
                        maxmin: true,
                        content: Feng.ctxPath + '/doctorLooked/doctor_addTask/' + eventData
                    });
                    this.layerIndex = index;
                }
                $('#calendar').fullCalendar('unselect');
            },
            timeFormat: 'H:mm',             //全局的日期显示格式(自定义成如12:00或12am等)
            slotEventOverlap: false,         //相同时间段的多个日程视觉上是否允许重叠
//          defaultDate  : '2018-09-29',
            schedulerLicenseKey: 'CC-Attribution-NonCommercial-NoDerivatives',
            dragRevertDuration: 200,
            unselectAuto: false,
            groupByResource: false,
            backgroundColor:"#FFFFFF",
            groupByDateAndResource: false,
            events: function(start,end,timezone, callback) {
                var s = start.format('YYYY-MM-DD HH:mm:ss');
                var e = end.format('YYYY-MM-DD HH:mm:ss');
                var d = new Date(e);
                var t = d.setSeconds(-1);
                var timestamp4 = new Date(t);
                var YY = timestamp4.getFullYear();
                var MM = timestamp4.getMonth() + 1;
                var DD = timestamp4.getDate();
                var hh = timestamp4.getHours();
                var mm = timestamp4.getMinutes();
                var ss = timestamp4.getSeconds();
                if(MM < 10 ){
                    MM = "0" + MM
                }else if(DD < 10 ){
                    DD = "0" + DD
                }
                var time = YY + "-" + MM + "-" + DD + " " + hh + ":" + mm + ":" + ss;
                var timeSlot = s + "," + time ;
                $.ajax({
                    url: Feng.ctxPath +'/doctorLooked/getDataList/' + timeSlot,
                    dataType:'json',
                    type: 'POST',
                    success:function(data) {
                        var avcit = [];
                        var events =[];
                        $.each(data,function (key,value) {
                            var obj =  {
                                id: value.customerId,
                                title: value.appointmentPayService ,
                                start: new Date(Date.parse(value.startTime)),
                                end: new Date(Date.parse(value.endTime)),
                                customerName: value.customerName,
                                resourceId:value.id,
                                medicalRecordNumber:value.medicalRecordNumber,
                                customerPhone:value.customerPhone,
                                customerAge:value.customerAge,
                                doctor:value.doctor,
                                arrivalStore:value.arrivalStore,
                                fieldTc:value.fieldTc,
                                remarks:value.remarks,
                                firstVisitDate:value.firstVisitDate,
                                filingTime:value.filingTime,
                                archiving:value.archiving,
                                birthday:value.birthday,
                                createAppointmentTime:value.createAppointmentTime,
                                arrivalStatus:value.arrivalStatus,
                                customerStatus:value.customerStatus,
                                reservationsId:value.reservationsId,
                                accountarrears:value.accountarrears,
                                yellowNumber:value.yellowNumber
                            };
                            if(value.arrivalStatus == '1'){
                                obj.backgroundColor = "#4099ff";
                                obj.borderColor = "white";
                            }else if(value.arrivalStatus == '2'){
                                obj.backgroundColor = "#10428b";
                                obj.borderColor = "white";
                            }else if(value.arrivalStatus == '3'){
                                obj.backgroundColor = "#ffba40";
                                obj.borderColor = "white";
                            }else if(value.arrivalStatus == '4'){
                                obj.backgroundColor = "#2dc87e";
                                obj.borderColor = "white";
                            }else if(value.arrivalStatus == '5'){
                                obj.backgroundColor = "#61b740";
                                obj.borderColor = "white";
                            }else if(value.arrivalStatus == '6'){
                                obj.backgroundColor = "#017cdc";
                                obj.borderColor = "white";
                            }else if(value.arrivalStatus == '7'){
                                obj.backgroundColor = "gray";
                                obj.borderColor = "white";
                            }
                            events.push(obj)
                        });
                        callback(events,avcit);
                    }
                });
                $.ajax({
                    url: Feng.ctxPath +'/doctorLooked/getListed/' + timeSlot,
                    dataType:'json',
                    type: 'POST',
                    success:function(data) {
                        $("#calendar").fullCalendar('refetchResources')
                        var doc =[];
                        for(var i= 0,arr={};i<data.length;i++){
                            arr={
                                id:data[i].id,
                                title:data[i].doctor
                            };
                            doc.push(arr);
                            $('#calendar').fullCalendar('addResource', {
                                id:data[i].id,
                                title:data[i].doctor
                            });
                        }
                    }
                });
            },
            eventClick: function(calEvent, jsEvent, view){
                arr= calEvent;
                $('a').removeClass('shadow');
                $(this).css("border-color","white ");
                $(this).addClass('shadow');
                var start = calEvent.start.format('YYYY-MM-DD');
                var starts = calEvent.start.format('HH:mm');
                var end = calEvent.end.format('HH:mm');
                var date = new Date();
                var time = date .getFullYear() + "-" + (date .getMonth()+1) + "-" + date .getDate();
                var startTime = new Date(start.replace("-", "/").replace("-", "/"));
                var endtime = new Date(time.replace("-", "/").replace("-", "/"));
                jsEvent.stopPropagation();
                $(this).attr('id',calEvent.id);

                var eds =
                    '<div style="color: #555555;padding-top: 8px;">' +
                    '<div><span style="color: #319dbc;font-size: 21px;font-weight: bold;padding-left: 15px;cursor:pointer;" onclick="openBilee('+"'"+calEvent.id+"'"+')">'+calEvent.customerName+'</span>' +
                    '<span style="font-size: 18px;font-weight: 200;margin: 0 15px;">'+calEvent.arrivalStore+'</span><span style="font-size: 18px;font-weight: 200;">'+calEvent.customerStatus+'</span></div>' +
                    '<div style="padding: 3px 15px;"><span>'+calEvent.medicalRecordNumber+'</span></div>' +
                    '<div style="padding: 3px  15px;"><span>'+calEvent.customerPhone+'</span></div>' +
                    '<div style="padding: 3px  15px;"><span>'+start+'('+calEvent.doctor+')</span></div>' +
                    '<div style="color: #319DB5;padding:  3px 0"><span>今日预约【<span>0</span>】</span><span>之后预约【<span>0</span>】</span><span>之前预约【<span>0</span>】</span></div>' +
                    '<div style="padding: 10px 0 15px;border-top: 1px solid #cccccc">' +
                    '<ul class="ulBox">' +
                    '<li><span>预约时间</span><span style="color: black;font-weight: bold;font-size: 24px;">'+starts+'-'+end+'</span></li>' +
                    '<li><span>咨询师</span><span>'+calEvent.fieldTc+'</span></li>' +
                    '<li><span>预约医生</span><span>'+calEvent.doctor+'</span></li>' +
                    '<li><span>预约项目</span><span>'+calEvent.title+'</span></li>' +
                    '<li style="vertical-align:middle;"><span>预约备注</span><span title="'+calEvent.remarks+'" style="display: inline-block;width: 280px;overflow: hidden;white-space: nowrap;text-overflow: ellipsis;">'+calEvent.remarks+'</span></li>' +
                    '<li><span>初诊日期</span><span>'+calEvent.firstVisitDate+'</span></li>' +
                    '<li><span>创建时间</span><span>'+calEvent.createAppointmentTime+'</span></li>' +
                    '<li><span>创建人</span><span>'+calEvent.archiving+'</span></li>' +
                    '<li><span>黄页编号</span><span style="display: inline-block;width: 100px;">'+calEvent.yellowNumber+'</span><a style="color: brown" href="javascript:;" onclick="numberedModification('+"'"+calEvent.id+"','"+calEvent.yellowNumber+"'"+')">修改</a></li>' +
                    '</ul>' +
                    '</div>' +
                    '</div>';
                var ads1 =
                    '<div class="btnBox"><p class="btnBox" style="padding: 0;">' +
                    '<button type="button" class="btn" onclick="modifyAppointment('+"'"+calEvent.id+"'"+')">修改</button> ' +
                    '<button type="button" class="btn" onclick="registerAppointment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">挂号</button> ' +
                    '<button type="button" class="btn" onclick="sureAppointment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">确定</button> ' +
                    '<button type="button" class="btn" onclick="cancelAppointment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">取消</button> ' +
                    '<button type="button" class="btn" onclick="appointment('+"'"+calEvent.id+"','"+calEvent.reservationsId+"','"+calEvent.doctor+"'"+')">再预约</button></p> ' +
                    '<button type="button" class="btn" onclick="printingAppointment('+"'"+calEvent.id+"'"+')">打印</button> ' +
                    '<button type="button" class="btn" onclick="shortMessage('+"'"+calEvent.id+"'"+')">短信</button> ' +
                    '</div>';

                var ads2 =
                    '<div class="btnBox">' +
                    '<button type="button" class="btn" onclick="modifyAppointment('+"'"+calEvent.id+"'"+')">修改</button> ' +
                    '<div class="btn-group dropup" style="display: inline-block;border: 1px solid #cccccc;border-radius:4px;">' +
                    '<button type="button" style="background: white;color: #333333;width: 100px;padding: 4px;border-right: 1px solid #cccccc;" class="btn" id="showTxt" onclick="startTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">开始治疗</button>' +
                    '<button type="button" style="background: white;color: #333333;width: 26px;padding: 4px;border-left: 1px solid #cccccc;" class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' +
                    '<span class="caret"></span><span class="sr-only">Toggle Dropdown</span></button>' +
                    '<ul class="dropdown-menu" style="color: #333333;min-width: 100%;border: 1px solid #cccccc;text-align: center">' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="registerAppointment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">挂号</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="startTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">开始治疗</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="completionTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">完成治疗</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="alreadyLeave('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">已离开</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="fallbackAction('+"'"+calEvent.id+"','"+calEvent.customerName+"','"+calEvent.arrivalStatus+"'"+',arr)">回退</li></ul>' +
                    '</div> '+
                    '<button type="button" class="btn" onclick="appointment('+"'"+calEvent.id+"','"+calEvent.reservationsId+"','"+calEvent.doctor+"'"+')">再预约</button> ' +
                    '<button type="button" class="btn" onclick="printingAppointment('+"'"+calEvent.id+"'"+')">打印</button> ' +
                    '<button type="button" class="btn" onclick="shortMessage('+"'"+calEvent.id+"'"+')" style="margin-top: 8px">短信</button> ' +
                    '</div>';

                var ads3 =
                    '<div class="btnBox">' +
                    '<button type="button" class="btn" onclick="modifyAppointment('+"'"+calEvent.id+"'"+')">修改</button> ' +
                    '<div class="btn-group dropup" style="display: inline-block;border: 1px solid #cccccc;border-radius:4px;">' +
                    '<button type="button" style="background: white;color: #333333;width: 100px;padding: 4px;border-right: 1px solid #cccccc;" class="btn" id="showTxt" onclick="completionTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">完成治疗</button>' +
                    '<button type="button" style="background: white;color: #333333;width: 26px;padding: 4px;border-left: 1px solid #cccccc;" class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' +
                    '<span class="caret"></span><span class="sr-only">Toggle Dropdown</span></button>' +
                    '<ul class="dropdown-menu" style="color: #333333;min-width: 100%;border: 1px solid #cccccc;text-align: center">' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="registerAppointment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">挂号</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="startTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">开始治疗</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="completionTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">完成治疗</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="alreadyLeave('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">已离开</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="fallbackAction('+"'"+calEvent.id+"','"+calEvent.customerName+"','"+calEvent.arrivalStatus+"'"+',arr)">回退</li></ul>' +
                    '</div> '+
                    '<button type="button" class="btn" onclick="appointment('+"'"+calEvent.id+"','"+calEvent.reservationsId+"','"+calEvent.doctor+"'"+')">再预约</button> ' +
                    '<button type="button" class="btn" onclick="printingAppointment('+"'"+calEvent.id+"'"+')">打印</button> ' +
                    '<button type="button" class="btn" onclick="shortMessage('+"'"+calEvent.id+"'"+')" style="margin-top: 8px">短信</button> ' +
                    '</div>';

                var ads4 =
                    '<div class="btnBox">' +
                    '<button type="button" class="btn" onclick="modifyAppointment('+"'"+calEvent.id+"'"+')">修改</button> ' +
                    '<div class="btn-group dropup" style="display: inline-block;border: 1px solid #cccccc;border-radius:4px;">' +
                    '<button type="button" style="background: white;color: #333333;width: 100px;padding: 4px;border-right: 1px solid #cccccc;" class="btn" id="showTxt" onclick="alreadyLeave('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">已离开</button>' +
                    '<button type="button" style="background: white;color: #333333;width: 26px;padding: 4px;border-left: 1px solid #cccccc;" class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' +
                    '<span class="caret"></span><span class="sr-only">Toggle Dropdown</span></button>' +
                    '<ul class="dropdown-menu" style="color: #333333;min-width: 100%;border: 1px solid #cccccc;text-align: center">' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="registerAppointment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">挂号</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="startTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">开始治疗</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="completionTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">完成治疗</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="alreadyLeave('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">已离开</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="fallbackAction('+"'"+calEvent.id+"','"+calEvent.customerName+"','"+calEvent.arrivalStatus+"'"+',arr)">回退</li></ul>' +
                    '</div> '+
                    '<button type="button" class="btn" onclick="appointment('+"'"+calEvent.id+"','"+calEvent.reservationsId+"','"+calEvent.doctor+"'"+')">再预约</button> ' +
                    '<button type="button" class="btn" onclick="printingAppointment('+"'"+calEvent.id+"'"+')">打印</button> ' +
                    '<button type="button" class="btn" onclick="shortMessage('+"'"+calEvent.id+"'"+')" style="margin-top: 8px">短信</button> ' +
                    '</div>';

                var ads5 =
                    '<div class="btnBox">' +
                    '<button type="button" class="btn" onclick="modifyAppointment('+"'"+calEvent.id+"'"+')">修改</button> ' +
                    '<div class="btn-group dropup" style="display: inline-block;border: 1px solid #cccccc;border-radius:4px;">' +
                    '<button type="button" style="background: #F2F2F2;color: #333333;width: 100px;padding: 4px;border-right: 1px solid #cccccc;pointer-events: none;" class="btn" id="showTxt">已离开</button>' +
                    '<button type="button" style="background: white;color: #333333;width: 26px;padding: 4px;border-left: 1px solid #cccccc;" class="btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">' +
                    '<span class="caret"></span><span class="sr-only">Toggle Dropdown</span></button>' +
                    '<ul class="dropdown-menu" style="color: #333333;min-width: 100%;border: 1px solid #cccccc;text-align: center">' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="registerAppointment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">挂号</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="startTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">开始治疗</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="completionTreatment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">完成治疗</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;pointer-events: none;background: #F2F2F2;" onclick="alreadyLeave('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">已离开</li>' +
                    '<li style="cursor:pointer;margin: 4px 0;padding: 4px 0;" onclick="fallbackAction('+"'"+calEvent.id+"','"+calEvent.customerName+"','"+calEvent.arrivalStatus+"'"+',arr)">回退</li></ul>' +
                    '</div> '+
                    '<button type="button" class="btn" onclick="appointment('+"'"+calEvent.id+"','"+calEvent.reservationsId+"','"+calEvent.doctor+"'"+')">再预约</button> ' +
                    '<button type="button" class="btn" onclick="printingAppointment('+"'"+calEvent.id+"'"+')">打印</button> ' +
                    '<button type="button" class="btn" onclick="shortMessage('+"'"+calEvent.id+"'"+')" style="margin-top: 8px">短信</button> ' +
                    '</div>';

                var ads6 =
                    '<div class="btnBox">' +
                    '<button type="button" class="btn" onclick="modifyAppointment('+"'"+calEvent.id+"'"+')">修改</button> ' +
                    '<button type="button" class="btn" onclick="appointment('+"'"+calEvent.id+"','"+calEvent.reservationsId+"','"+calEvent.doctor+"'"+')">再预约</button> ' +
                    '<button type="button" class="btn" onclick="fallbackAction('+"'"+calEvent.id+"','"+calEvent.customerName+"','"+calEvent.arrivalStatus+"'"+',arr)">回退</button> ' +
                    '<button type="button" class="btn" onclick="printingAppointment('+"'"+calEvent.id+"'"+')">打印</button> ' +
                    '<button type="button" class="btn" onclick="shortMessage('+"'"+calEvent.id+"'"+')">短信</button> ' +
                    '</div>';

                var ads7 =
                    '<div class="btnBox"><p class="btnBox" style="padding: 0;">' +
                    '<button type="button" class="btn" onclick="modifyAppointment('+"'"+calEvent.id+"'"+')">修改</button> ' +
                    '<button type="button" class="btn" onclick="registerAppointment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">挂号</button> ' +
                    '<button type="button" class="btn" onclick="cancelAppointment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">取消</button> ' +
                    '<button type="button" class="btn" onclick="appointment('+"'"+calEvent.id+"','"+calEvent.reservationsId+"','"+calEvent.doctor+"'"+',arr)">再预约</button>' +
                    '<button type="button" class="btn" onclick="printingAppointment('+"'"+calEvent.id+"'"+')">打印</button></p>  ' +
                    '<button type="button" class="btn" onclick="noSureAppointment('+"'"+calEvent.id+"','"+calEvent.customerName+"'"+',arr)">取消确定</button> ' +
                    '<button type="button" class="btn" onclick="shortMessage('+"'"+calEvent.id+"'"+')">短信</button> ' +
                    '</div>';

                if(calEvent.arrivalStatus == '1'){
                    test = layer.open({
                        type:4,
                        tips:[2,'#ffffff'],
                        closeBtn:0,
                        area:['405px','auto'],
                        content:['<div>'+eds+''+ads1+'</div>','#'+calEvent.id+'']
                    });
                }else if(calEvent.arrivalStatus == '2'){
                    test = layer.open({
                        type:4,
                        tips:[2,'#ffffff'],
                        closeBtn:0,
                        area:['405px','auto'],
                        content:['<div>'+eds+''+ads2+'</div>','#'+calEvent.id+'']
                    });
                }else if(calEvent.arrivalStatus == '3'){
                    test = layer.open({
                        type:4,
                        tips:[2,'#ffffff'],
                        closeBtn:0,
                        area:['405px','auto'],
                        content:['<div>'+eds+''+ads3+'</div>','#'+calEvent.id+'']
                    });
                }else if(calEvent.arrivalStatus == '4'){
                    test = layer.open({
                        type:4,
                        tips:[2,'#ffffff'],
                        closeBtn:0,
                        area:['405px','auto'],
                        content:['<div>'+eds+''+ads4+'</div>','#'+calEvent.id+'']
                    });
                }else if(calEvent.arrivalStatus == '5'){
                    test = layer.open({
                        type:4,
                        tips:[2,'#ffffff'],
                        closeBtn:0,
                        area:['405px','auto'],
                        content:['<div>'+eds+''+ads5+'</div>','#'+calEvent.id+'']
                    });
                }else if(calEvent.arrivalStatus == '7'){
                    test = layer.open({
                        type:4,
                        tips:[2,'#ffffff'],
                        closeBtn:0,
                        area:['405px','auto'],
                        content:['<div>'+eds+''+ads6+'</div>','#'+calEvent.id+'']
                    });
                }else if(calEvent.arrivalStatus == '6'){
                    if(startTime > endtime){
                        test = layer.open({
                            type:4,
                            tips:[2,'#ffffff'],
                            closeBtn:0,
                            area:['405px','auto'],
                            content:['<div>'+eds+''+ads7+'</div>','#'+calEvent.id+'']
                        });
                    }else {
                        test = layer.open({
                            type:4,
                            tips:[2,'#ffffff'],
                            closeBtn:0,
                            area:['405px','auto'],
                            content:['<div>'+eds+''+ads1+'</div>','#'+calEvent.id+'']
                        });
                    }
                }

            },
            eventRender: function (calEvent,element, view) {//在呈现事件时触发
                if(calEvent.customerName == ""||calEvent.customerName == null){
                    element.prepend("<div class='myfc-title'><span>新建预约</span></div>");
                }
            },
            eventAfterRender:function( calEvent, element, view ) {
                var data3 = parseInt(calEvent.end._d - calEvent.start._d) / 1000 / 60;
                if(element[0].clientWidth < 25){
                    element[0].innerHTML = "";
                }else if(element[0].clientWidth >= 25 && element[0].clientWidth < 45){
                    element[0].innerHTML = "";
                    element.prepend("<div class='myfc-title'><span style='font-size: 18px;font-weight: bold;letter-spacing: 3px;'>"+calEvent.customerName+"</span></div>");
                }else {
                    if(calEvent.accountarrears != 0){
                        if(data3 < 61){
                            element.prepend("<div class='myfc-title'><span style='font-size: 18px;font-weight: bold;letter-spacing: 3px;'>"+calEvent.customerName+"</span></div>" +
                                "<div style='position: absolute;right: 2px;top: 1px;color: white;background: red;padding: 0 2px;border: 1px solid white;border-radius: 50%;font-size: 0.5em'>欠</div>");
                        }else {
                            element.prepend("<div class='myfc-title'><span style='font-size: 18px;font-weight: bold;letter-spacing: 3px;'>"+calEvent.customerName+"</span></div><div style='position: absolute;bottom: 5px;'>"+calEvent.remarks+"</div>" +
                                "<div style='position: absolute;right: 2px;top: 1px;color: white;background: red;padding: 0 2px;border: 1px solid white;border-radius: 50%;font-size: 0.5em'>欠</div>");
                        }
                    }else {
                        if(data3 < 61){
                            element.prepend("<div class='myfc-title'><span style='font-size: 18px;font-weight: bold;letter-spacing: 3px;'>"+calEvent.customerName+"</span></div>");
                        }else {
                            element.prepend("<div class='myfc-title'><span style='font-size: 18px;font-weight: bold;letter-spacing: 3px;'>"+calEvent.customerName+"</span></div><div style='position: absolute;bottom: 5px;'>"+calEvent.remarks+"</div>");
                        }

                    }
                }
            },
            //拖拽到其它地方
            eventDrop:function (event, delta, revertFunc, jsEvent, ui, view) {
                if(event.arrivalStatus == '5'||event.arrivalStatus == '7'){
                    alert("此状态不能修改！")
                    revertFunc()
                }else {
                    if(confirm("您确定要修改预约么？")) {
                        var startTime = event.start.format('YYYY-MM-DD HH:mm:ss');
                        var endTime = event.end.format('YYYY-MM-DD HH:mm:ss');
                        var doctorId = event.resourceId;
                        var id = event.id;
                        var sed = startTime + "," + endTime + "," + doctorId + "," + id;

                        $.ajax({
                            url: Feng.ctxPath + '/doctorLooked/draftingUpdate/' + sed,
                            dataType: 'json',
                            type: 'POST',
                            success: function (data) {
                                Feng.success('修改成功!');
                            },
                            error:function (data) {
                                revertFunc()
                            }
                        });
                    }else {
                        revertFunc()
                    }
                }
            },
            //往下拖框
            eventResize:function (event, delta, revertFunc, jsEvent, ui, view) {
                if(event.arrivalStatus == '5'||event.arrivalStatus == '7'){
                    alert("此状态不能修改！")
                    revertFunc()
                }else {
                    if(confirm("您确定要修改预约么？")) {
                        var startTime = event.start.format('YYYY-MM-DD HH:mm:ss');
                        var endTime = event.end.format('YYYY-MM-DD HH:mm:ss');
                        var doctorId = event.resourceId;
                        var id = event.id;
                        var sed = startTime + "," + endTime + "," + doctorId + "," + id;
                        $.ajax({
                            url: Feng.ctxPath + '/doctorLooked/draftingUpdate/' + sed,
                            dataType: 'json',
                            type: 'POST',
                            success: function (data) {
                                Feng.success('修改成功!');
                            },
                            error:function (data) {
                                revertFunc()
                            }
                        });
                    }else {
                        revertFunc()
                    }
                }
            }
        });
        $("#calendar").on('click','h2',function () {
            laydate({
                istime: true,
                format: 'YYYY-MM-DD',
                choose:function (value) {
                    $('#calendar').fullCalendar( 'gotoDate', value )
                }
            })
        })
    });
    /**
     * 跳转医生个人视图
     */
    $("#calendar").on('click','th.fc-resource-cell',function () {
        var id = $(this).attr("data-resource-id");
        window.location = "${ctxPath}/customer/customer_doctorWeek/" + id;
    });

    var pageStart = 1;
    var pageSize = 10;
    //查询
    function search() {
        var reach = document.getElementById("reach").value;
        if(reach != ""){
            $.ajax({
                url: Feng.ctxPath + "/customer/getCustomerByStore",
                type: "post",
                data:{
                    reach:reach,
                    pageStart:pageStart,
                    pageSize:pageSize
                },
                success: function (data) {
                    $("#dataBox").show();
                    var patient = "";
                    for (var i = 0; i < data.length; i++) {
                        patient += '<li style="padding: 10px 0 10px 10px;border-bottom: 1px solid #cccccc" id="' + data[i].id + '" class="' + data[i].id + '">' +
                            '<p><span>' + data[i].customerName + '</span>&nbsp;&nbsp;<span>' + data[i].sex + '</span>&nbsp;&nbsp;<span>' + data[i].customerAge + '</span>岁</p>' +
                            '<p>' + data[i].customerPhone + '</p>' +
                            '<p>' + data[i].arrivalStore + '</p>' +
                            '</li>'
                    }
                    $("#dataUl").html(patient);
                    if ((pageStart * pageSize) > data.length) {
                        $(".js-load-more").hide();
                    }else{
                        $(".js-load-more").show();
                    }
                },
                error: function (data) {
                    alert('内部故障!');
                }
            });
        }else {
            $("#dataBox").hide();
        }

    }
    $(document).on('click', '.js-load-more', function () {
        pageStart++;
        search();
    });

    $(document).click(function () {
        $("#dataBox").hide();
    });

    $("#dataUl").on('click', 'li', function () {
        var ide = $(this).attr('class');
        $("#dataBox").hide();
        var index = layer.open({
            type: 2,
            title: '到店客户详情',
            area: ['100%', '100%'], //宽高
            fix: true, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/consultant/to_openBileLists/' + ide
        });
        this.layerIndex = index;
    })

    reservationMatching = function () {
        var customerPhone = $('#reach').val();
        var str = customerPhone.replace(/(^\s*)|(\s*$)/g, "");
        var customerName = $('#customerName').val();
        if (!(/^\d{5,13}$/).test(str)) {
            alert("电话为5到13位的数字，请重新输入...");
            return;
        }
        if (customerPhone == null || customerPhone == "") {
            alert("请输入电话号码！");
            return;
        }
        var index = layer.open({
            type: 2,
            title: '预约客户电话匹配',
            area: ['90%', '90%'], //宽高
            fix: true, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/customer/to_reservation_matching/' + str
        });
        this.layerIndex = index;
    };

</script>

@}